﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace MLOCore
{
    public class SongFile : INotifyPropertyChanged
    {
        protected Library _parent;

        public Library Parent
        {
            get
            {
                return _parent;
            }
        }

        private string _FileLocation;
        public string FileLocation
        {
            get
            {
                return _FileLocation;
            }
            set
            {
                if (_FileLocation != value)
                {
                    _FileLocation = value;
                    OnPropertyChanged("FileLocation");
                }
            }
        }

        protected NameValueNodeDictionary nodes;

        public NameValueNodeDictionary Nodes
        {
            get
            {
                nodes = nodes ?? new NameValueNodeDictionary();
                return nodes;
            }
        }

        public SongFile()
        {
        }

        public SongFile(Library parent, string file)
        {
            Guard.IsNotNull(parent, "parent");
            Guard.IsNotNull(file, "file");

            _parent = parent;

            string relative = file.Replace(parent.ParentDirectory, string.Empty);
            if (relative.StartsWith("\\")) relative = relative.Remove(0, 1);

            FileLocation = relative;
        }


        #region INotifyPropertyChanged Members

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
